<template>
	<view class="c-wrap">
		<view class="submitBar">
			<view class="submitBar-L">
				<view class="submitBar-LImg">
					<view class="submitBar-LCount" v-if="gSalesTicketGoodsList.length > 0">
						{{gSalesTicketGoodsList.length}}
					</view>
					<image src="../../static/images/icon-addsales-sbcart.png" @click="onSkipTap('shopCartSelect')">
					</image>
				</view>
				<text>金额：￥{{amount}}</text>
			</view>
			<view class="submitBar-R">
				<g-btn :title="title" :customstyle="{width:'200rpx', height: '70rpx'}" @click="onConfirmTap"></g-btn>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			title: {
				type: String,
				default: '选好了'
			},
			amount: {
				type: [Number, String],
				default: 0
			}
		},
		data() {
			return {

			}
		},
		onLoad(options) {

		},
		methods: {
			onSkipTap(type, index) {
				const urlObj = {
					shopCartSelect: () => {
						const page = getCurrentPages()
						const pageItem = page?.find(item => item.route ===
							'pages/commodityManagement/shopCartSelect')
						if (pageItem) return
						uni.navigateTo({
							url: '/pages/commodityManagement/shopCartSelect'
						})
					}
				}
				this.$g_util.navigationTo(urlObj, type)
			},
			onConfirmTap() {
				const page = getCurrentPages()
				const pageIndex = page?.findIndex(item => item.route ===
					'pages/salesManagerment/addSalesOrder')
				if (pageIndex != -1 && pageIndex != page.length - 1) {
					uni.navigateBack({
						delta: page.length - 1 - pageIndex
					})
				}
				this.$emit('confirm')
			}
		}
	}
</script>
<style scoped lang="scss">
	.submitBar {
		position: fixed;
		left: 0;
		bottom: 0;
		width: 690rpx;
		height: 100rpx;
		background-color: #fff;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0 30rpx;
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);
		box-sizing: content-box;
		box-shadow: 0 0 10rpx 0rpx rgba(0, 0, 0, 0.1);
		z-index: 999;
	}

	.submitBar-L {
		display: flex;
		align-items: center;

		text {
			margin-left: 30rpx;
			font-size: 30rpx;
		}
	}

	.submitBar-LImg {
		position: relative;
		width: 38rpx;
		height: 38rpx;

		image {
			width: 38rpx;
			height: 38rpx;
		}
	}
	
	.submitBar-LCount {
		display: flex;
		align-items: center;
		justify-content: center;
		position: absolute;
		right: -10rpx;
		top: -10rpx;
		width: 30rpx;
		height: 30rpx;
		border-radius: 50%;
		background-color: #ff3333;
		color: #fff;
		font-size: 20rpx;
	}

	.submitBar-R {}
</style>
